package com.freshmarket.freshmarket.controller;


import com.freshmarket.freshmarket.service.ILimitedTimeOfferService;
import com.freshmarket.freshmarket.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.text.ParseException;
import java.util.ArrayList;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Squirrel
 * @since 2020-09-04
 */
@RestController
@RequestMapping("/freshmarket/limited-time-offer")
public class LimitedTimeOfferController {
    @Autowired
    private ILimitedTimeOfferService limitedTimeOfferService;

    @RequestMapping("/findProductType")
    public Result findProductType(){
        return Result.successResult(limitedTimeOfferService.findProductType());
    }


    @RequestMapping("/pageKillProduct")
    public Result findByProductId(@RequestParam(defaultValue = "1")int index, @RequestParam(defaultValue = "2")int size, int id) throws ParseException {

        return Result.successResult(limitedTimeOfferService.pageKillProduct(index,size,id));
    }
    @RequestMapping("/address")
    public Result Address(){
        return Result.successResult(limitedTimeOfferService.Address());
    }
    @RequestMapping("/user")
    public Result user(HttpSession session){
        return Result.successResult(session.getAttribute("user"));
    }
}

